home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / WMS.CAB / plugin_dialog.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  10.5 KB  |  332 lines

  1. ∩╗┐<%@ Language=VBScript CODEPAGE=65001 %>
  2. <!--#include file="include/wmsLocStrings.inc"-->
  3. <!--#include file="include/wmsHeader.inc"-->
  4. <!--#include file="include/wmsServerHash.inc"-->
  5. <!--#include file="include/wmsPlugins.inc"-->
  6. <!--#include file="include/wmsError.inc"-->
  7. <%
  8. '+-------------------------------------------------------------------------
  9. '
  10. '  Microsoft Windows Media
  11. '  Copyright (C) Microsoft Corporation. All rights reserved.
  12. '
  13. '  File:       Plugin_Dialog.asp
  14. '
  15. '  Contents:
  16. '
  17. '--------------------------------------------------------------------------
  18.  
  19. BeginErrorHandling
  20. ConnectToPlugin
  21.  
  22. on error resume next
  23.  
  24. Dim strErrorDescription
  25. Dim bOpIsRename
  26. Dim bError
  27. Dim strNewName
  28. Dim strHelpTopic
  29. Dim strPageTitle
  30. Dim strOp
  31. Dim strPluginIndex
  32.  
  33. strOp = GetPostOrQsVal( "op" )
  34. strPluginIndex = trim( GetPostOrQsVal( "pluginIndex" ) )
  35.  
  36. bOpIsRename = FALSE
  37.  
  38. if( 0 = StrComp( "rename", strOp, vbTextCompare ) ) then
  39.     strPageTitle = L_RENAMEPL_TEXT
  40.     bOpIsRename = TRUE
  41.     strHelpTopic = H_PLRENAMETOPIC
  42. elseif( 0 = StrComp( "duplicate", strOp, vbTextCompare ) ) then
  43.     strPageTitle = L_DUPLICATEPL_TEXT
  44.     bOpIsRename = FALSE
  45.     strHelpTopic = H_PLDUPLICATETOPIC
  46. end if
  47.  
  48. bError = FALSE
  49.  
  50. strNewName = Left( SafeUnescape( GetFormStr( "newPluginName" ) ), MAX_LEN_PLUGINNAME )
  51.  
  52. if( 0 < Len( strNewName ) ) then
  53.     if bOpIsRename then
  54.         if PluginNameIsLegal( strNewName ) then
  55.             g_objPlugin.Name = strNewName
  56.         end if
  57.     else
  58.         ClearError
  59.         g_objPluginCollection.Clone CStr( strNewName ), g_objPlugin
  60.     end if
  61.  
  62.     if( ErrorDetected( "name" ) ) then
  63.         bError = TRUE
  64.         Session( "PageReloadedToDisplayError" ) = 1
  65.     else    
  66.         Response.Clear
  67.         if ( FALSE = IsEmpty( g_objPubPoint ) ) then
  68.             Response.Redirect( "../pubpoints/pubpoint_props.asp?server=" & g_strQueryStringServer & "&ppID=" & g_strPubPointID & "&category=" & g_strCategory & "&pluginIndex=" & strPluginIndex )
  69.         else
  70.             Response.Redirect( "../server_props.asp?server=" & g_strQueryStringServer & "&category=" & g_strCategory & "&pluginIndex=" & strPluginIndex )
  71.         end if
  72.     end if
  73. end if
  74.  
  75. strErrorDescription = Left( CStr( GetPostOrQsVal( "error" ) ), MAX_PATH )
  76.  
  77. '////////////////////////////////////////////////////////////////
  78. Function CreateNewPluginName( strPPName )
  79.     Dim strTemplate    
  80.     strTemplate = L_COPYOFPLUGTEMPL_TEXT
  81.     CreateNewPluginName = Replace( strTemplate, "___", strPPName, 1 )
  82. End Function
  83.  
  84. '/////////////////////////////////////////////////////////////////////
  85. Function PluginNameIsLegal( strPluginName )
  86.     PluginNameIsLegal = TRUE
  87.     Dim regEx
  88.     Set regEx = New RegExp
  89.     
  90.     regEx.Pattern = "/%|\\|\&|\<|\>|\f|\n|\r|\x22|\x201C|\x201D|\x201E/gi"
  91.     regEx.IgnoreCase = TRUE
  92.     regEx.Global = TRUE
  93.     regEx.Multiline = TRUE
  94.     if( TRUE = regEx.Test( strPluginName ) ) then
  95.         PluginNameIsLegal = FALSE
  96.         Exit Function
  97.     end if
  98. End Function
  99.  
  100. WriteHTMLHeader( strPageTitle ) 
  101. %>
  102. <link rel="stylesheet" type="text/css" href="<%= Session( "cssName" ) %>">
  103. <% WritePluginJSUtils %>
  104. <script language="JavaScript">
  105. <!--
  106. /*@cc_on @*/
  107.  
  108. var g_bNameAlerted = false;
  109.  
  110. <% WriteCommonJSUtils %>
  111.  
  112. var dbgNumFilterWarnings = 0;
  113.  
  114. //////////////////////////////////////////////////////////////////////////
  115. function InitFilters()
  116. {
  117.     <% jsTRY %>
  118.     var szNewPluginName = new String( document.pluginForm.newPluginName.value );
  119.     document.pluginForm.newPluginName.focus();
  120.     if( 0 >= szNewPluginName.length )
  121.     {
  122.         return;
  123.     }
  124.     else
  125.     {
  126.         document.pluginForm.newPluginName.disabled = false;
  127.         document.pluginForm.newPluginName.focus();
  128.     }
  129.  
  130.     var szOriginalPluginName;
  131.     szOriginalPluginName = new String( "<%= g_strPluginName %>" );
  132.     if( szNewPluginName.toUpperCase() == szOriginalPluginName.toUpperCase() )
  133.     {
  134.         document.pluginForm.ok.disabled = true;
  135.     }
  136.  
  137.     <% if "" <> GetPostOrQsVal( "error" ) then %>
  138.     HandleError();
  139.     <% end if %>
  140.     <% jsCATCH %>
  141. }
  142.  
  143. //////////////////////////////////////////////////////////////////////////
  144. function CheckPluginName()
  145. {
  146.     <% jsTRY %>
  147.     var szName;
  148.     var bCanBeEnabled;
  149.     var bValidName = false;
  150.     var szIllegalPluginNameChars;
  151.     var i;
  152.     
  153.     bCanBeEnabled = true;
  154.     szName = new String( document.pluginForm.newPluginName.value );
  155.     
  156.     // perform left trim
  157.     szName = szName.replace( /^\s+/, "" );
  158.  
  159.     // perform right trim
  160.     szName = szName.replace( /\s+$/, "" );
  161.     
  162.     if( ( 0 == szName.length ) || ( "<%= EscBackslashChar( ucase( g_strPluginName ) ) %>" == szName.toUpperCase() ) )
  163.     {
  164.         bCanBeEnabled = false;
  165.     }
  166.     
  167.     bValidName = false;
  168.     var szIllegalChars = /\\|\%|\&|\<|\>|\"|\f|\n|\r|\x22|\x201C|\x201D|\x201E/gi;
  169.     if( -1 == szName.search( szIllegalChars ) )
  170.     {
  171.         bValidName = true;
  172.     }
  173.     
  174.     if( false == bValidName )
  175.     {
  176.         document.pluginForm.newPluginName.style.color = "#ff0000";
  177.         document.pluginForm.ok.disabled = true;
  178.         window.status = "<%= L_INVALIDCHARSINPLNAME_TEXT & "\\ % & < > \" & chr(34) %>";
  179.         
  180.         if( false == g_bNameAlerted )
  181.         {
  182.             g_bNameAlerted = true;
  183.             window.alert( "<%= L_INVALIDCHARSINPLNAME_TEXT & "\n\\ % & < > \" & chr(34) %>" );
  184.             document.pluginForm.newPluginName.focus();
  185.         }
  186.     }
  187.     else
  188.     {
  189.         document.pluginForm.newPluginName.style.color = "#000000";
  190.         document.pluginForm.ok.disabled = ! bCanBeEnabled;
  191.         window.status = "";
  192.     }
  193.     <% jsCATCH %>
  194. }
  195.  
  196.  
  197. ///////////////////////////////////////////////////////////////////////
  198. function HandleError()
  199. {
  200.     <% jsTRY %>
  201.     <% if( "duplicate" = strErrorDescription ) then %>
  202.     window.alert("<%= RemoveDangerousCharacters( CStr( g_strDecodedServerName ) & L_DUPLICATENAME_TEXT ) %>");
  203.     <% elseif( "hostnotavailable" = strErrorDescription ) then %>
  204.     window.alert("<%= RemoveDangerousCharacters( CStr( g_strDecodedServerName ) & L_BADHOSTNAME_TEXT ) %>");
  205.     <% elseif( "nowms" = strErrorDescription ) then %>
  206.     window.alert("<%= RemoveDangerousCharacters( CStr( g_strDecodedServerName ) & L_NOWMS_TEXT ) %>");
  207.     <% elseif( "serviceerror" = strErrorDescription ) then %>
  208.     window.alert("<%= RemoveDangerousCharacters( CStr( g_strDecodedServerName ) & L_SERVICEINERROR_TEXT ) %>");
  209.     <% else %>
  210. //    document.location.replace( "pubpoint_collection.asp" );
  211.     <% end if %>
  212.     <% jsCATCH %>
  213. }
  214.  
  215.  
  216. ///////////////////////////////////////////////////////////////////////
  217. function ValidateInput()
  218. {
  219.     <% jsTRY %>
  220.     var szOriginalName;
  221.     var newPluginName;
  222.  
  223.     if( document.pluginForm.ok.disabled )
  224.     {
  225.         event.cancelBubble=1;
  226.         return false;
  227.     }
  228.     <% jsCATCH %>
  229. }
  230. -->
  231. </script>
  232. </head>
  233. <body bgcolor="<%= colorTabLight %>" topmargin="10" leftmargin="10" rightmargin="10" marginwidth="10" marginheight="10" onload="JavaScript:InitFilters();" oncontextmenu="JavaScript:event.cancelBubble=true;return false;">
  234. <% BeginErrorHandling %>
  235. </body>
  236.  
  237. <% WriteStdPluginForm %>
  238. <input type="hidden" name="op" value="<%= GetPostOrQsVal( "op" ) %>">
  239. <input type="hidden" name="pluginIndex" value="<%= GetPostOrQsVal( "pluginIndex" ) %>">
  240. <table cellspacing=0 cellpadding=4 <% if brMSIE = g_dwBrowserType then %>class="dialogframe" <% else %> bgcolor="lightgrey" <% end if %> border=3><tr><td>
  241. <table width="100%" cellspacing="5" cellpadding=0 cols="3" border="0">
  242. <tr>
  243.     <td width=40 valign="middle" align="left">
  244. <% if bOpIsRename then %>
  245.         <img src="img/rename_icon32.gif" valign="middle" width=32 height=32>
  246. <% else %>
  247.         <img src="img/dupplugin_icon32.gif" valign="middle" width=32 height=32>
  248. <% end if %>
  249.     </td>
  250.     <td valign="bottom" align="left" class="header">
  251. <% if bOpIsRename then %>
  252.         <%= Server.HTMLEncode( L_RENAMEPL_TEXT ) %>
  253. <% else %>
  254.         <%= Server.HTMLEncode( L_DUPLICATEPL_TEXT ) %>
  255. <% end if %>
  256.     </td>
  257. </tr>
  258. </table>
  259. <table width="100%" cellspacing="1" cellpadding="1" border="0">
  260. <tr>
  261.     <td width="32">
  262.          
  263.     </td>
  264.     <td align="left" valign="middle">
  265.     </td>
  266. </tr>
  267. <tr>
  268.     <td class="defaultcursor" colspan="2">
  269.         <% RenderWithErrorCheck Server.HTMLEncode( L_PLUGINNAMECOLON_TEXT ), "name" %>
  270.     </td>
  271. </tr>
  272. <tr>
  273.     <td align=left colspan="2">
  274.         <input 
  275.             type="text" 
  276.             maxlength="<%= Server.HTMLEncode( MAX_LEN_PLUGINNAME ) %>"
  277.             name="newPluginName" 
  278.             tabindex=1 
  279.             size="<% if brMSIE = g_dwBrowserType then %>60<% else %>80<% end if %>" <%
  280.         if bOpIsRename then %>
  281.             value="<% if( "" = qs("newPluginName") ) then Response.Write( RemoveSpecifiedChars( g_strPluginName, REGEXP_DANGEROUS_CHARS ) ) else Response.Write( RemoveSpecifiedChars( SafeUnescape( qs("newPluginName") ), REGEXP_DANGEROUS_CHARS ) ) end if %>"
  282.         <% else %>
  283.             value="<% 
  284.             if( 0 = Len( qs("newPluginName") ) ) then 
  285.                 strCopyName = CreateNewPluginName( g_strPluginName )
  286.             else 
  287.                 strCopyName = CreateNewPluginName( qs("newPluginName") )
  288.             end if 
  289.             Response.Write( RemoveDangerousCharacters( strCopyName ) ) %>"<%
  290.         end if %>
  291.             onKeyUp="JavaScript:CheckPluginName();"
  292.             onKeyDown="JavaScript:CheckPluginName();"
  293.             onChange="JavaScript:CheckPluginName();"
  294.             onPaste="JavaScript:CheckPluginName();"
  295.             AUTOCOMPLETE="OFF"
  296.             >
  297.     </td>
  298.     <td width=32>
  299.          
  300.     </td>
  301. </tr>
  302. </table>
  303. <p>
  304. <table cellspacing=4 cellpadding=0 border="0">
  305. <tr>
  306.     <td align=left>
  307.         <INPUT type="submit" name="ok" onclick="JavaScript:ValidateInput();" tabIndex=2 value="<%= Server.HTMLEncode( L_OKAYBUTTON_TEXT ) %>">
  308.     </td>
  309.     <td align=left>
  310.         <INPUT name="cancel" onclick="JavaScript:Cancel();" tabIndex="3" type=button value="<%= Server.HTMLEncode( L_CANCELBUTTONSPACED_TEXT ) %>"> 
  311.     </td>
  312.     <td align=left>
  313.         <INPUT name="help" onclick="JavaScript:DoHelp( '<%= H_PPLEVEL %>','<%= strHelpTopic %>' );" tabIndex=4 type=button value="<%= Server.HTMLEncode( L_HELPBUTTONSPACED_TEXT ) %>"> 
  314.     </td>
  315.     <td align=left>
  316.          
  317.     </td>
  318. </tr>
  319. </table>
  320. </td></tr></table>
  321.  
  322. </form>
  323. <% AlertUserWithPopupErrorDialog  %>
  324. <% OnErrorGoBack %>
  325. </body>
  326. </html>
  327. <% 
  328. EndErrorHandling "plugin_dialog.asp" 
  329.  
  330. on error resume next
  331. PluginsASPCleanup
  332. %>